import {NgModule, ErrorHandler} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {IonicApp, IonicModule, IonicErrorHandler, Refresher, Content} from 'ionic-angular';
import { MyApp } from './app.component';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from "@angular/common/http";
import {IonicStorageModule} from "@ionic/storage";
import {TranslateModule} from "@ngx-translate/core";
import {TranslateLoader} from "@ngx-translate/core";
import {ACLService} from "./acl/acl.service";
import {AppConfig} from "./appConfig";
import {AuthInterceptor} from "./net/auth.interceptor";
import {ZBar} from "@ionic-native/zbar";
import {TranslateHttpLoader} from "@ngx-translate/http-loader";
import {CommonService} from "./common.service";
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {Geolocation} from "@ionic-native/geolocation";
import {ImagePicker} from "@ionic-native/image-picker";
import {Camera} from "@ionic-native/camera";

export function createTranslateLoader(http: HttpClient) {
  //选择语言包
  return new TranslateHttpLoader(http, './assets/language/', '.json');
}
@NgModule({
  declarations: [
    MyApp,
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp, {
      // backButtonText: '返回',
      // iconMode: 'ios',
      // mode: 'ios',
      tabsHideOnSubPages: 'true',
      // pageTransition: 'wp-transition'
    }),
    HttpClientModule,
    IonicStorageModule.forRoot(),
    FormsModule,
    ReactiveFormsModule,
    TranslateModule.forRoot({
      loader: {

        provide: TranslateLoader,
        useFactory: (createTranslateLoader),
        deps: [HttpClient]
      }
    }),
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    ACLService,
    AppConfig,
    {provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true},
    ZBar,
    CommonService,
    Geolocation,
    ImagePicker,
    Camera
  ]
})
export class AppModule {}
